﻿namespace WebCoreEmptyToMiddleWare
{
    public class SelfMiddleware
    {
        private readonly RequestDelegate next;

        public SelfMiddleware(RequestDelegate next)
        {
            this.next = next;
        }

        public async Task InvokeAsync(HttpContext context) {
            Console.WriteLine("请求的类型："+ context.Request.Method); 
            await next.Invoke(context);
            Console.WriteLine("响应体长度："+context.Response.ContentLength);
            context.Items["Key1"] = "This is Middleware.Items";
        }
    }
}
